/** 
 * ================================================================================
 * 		Project		: Kompas Bola
 * 		File		: ListMatchAdapter.java
 * 		Description	: List Adapter from Match
 * 		Called		: MainActivity.java
 * ================================================================================
 * */
package com.kompas.bola.application.adapter;

import java.util.List;
import com.kompas.bola.application.R;
import com.kompas.bola.application.model.Content;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ListMatchAdapter extends BaseAdapter   {
	/** =========================================================================== */   
	private Activity activity;
	private List<Content> data;
	private static LayoutInflater inflater = null;
	private LinearLayout dLayoutMatch;
	private TextView tgl;
	private TextView team1;
	private TextView team2;
	private TextView skor;
	/** =========================================================================== */   
	public ListMatchAdapter(Activity a, List<Content> d) {
		activity 					= a;
		data 						= d;
		inflater 					= (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
	/** =========================================================================== */   
	public int getCount() {
		return data.size();
	}
	/** =========================================================================== */   
	public Object getItem(int position) {
		return position;
	}
	/** =========================================================================== */   
	public long getItemId(int position) {
		return position;
	}
	/** =========================================================================== */   
	public View getView(int position, View convertView, ViewGroup parent) {
		View vi 					= convertView;
				
		vi 							= inflater.inflate(R.layout.list_match, null);	
				
		tgl							= (TextView) vi.findViewById(R.id.tgl); // tgl
		team1						= (TextView) vi.findViewById(R.id.team1); // team1
		team2						= (TextView) vi.findViewById(R.id.team2); // team2
		skor 						= (TextView) vi.findViewById(R.id.skor); // skor1
		dLayoutMatch				= (LinearLayout)  vi.findViewById(R.id.layout_match); // layout
        
        Content bola				= new Content();
        bola 						= data.get(position);

        tgl.setText(bola.getKEY_DATE());
        team1.setText(bola.getKEY_TEAM1());
        team2.setText(bola.getKEY_TEAM2());
        skor.setText(bola.getKEY_SCORE1()+" - "+bola.getKEY_SCORE2());
        dLayoutMatch.setVisibility(View.VISIBLE);

		return vi;
	}
	/** =========================================================================== */   
}
